import request from '@/utils/request'

/**
 * 分页查询保养记录
 */
export function getMaintenancePage(params) {
  return request({
    url: '/maintenance/page',
    method: 'get',
    params
  })
}

/**
 * 根据车辆ID查询保养记录
 */
export function getMaintenanceListByVehicleId(vehicleId) {
  return request({
    url: `/maintenance/vehicle/${vehicleId}`,
    method: 'get'
  })
}

/**
 * 根据客户ID查询保养记录
 */
export function getMaintenanceListByCustomerId(customerId) {
  return request({
    url: `/maintenance/customer/${customerId}`,
    method: 'get'
  })
}

/**
 * 根据ID查询保养记录
 */
export function getMaintenanceById(id) {
  return request({
    url: `/maintenance/${id}`,
    method: 'get'
  })
}

/**
 * 新增保养记录
 */
export function addMaintenance(data) {
  return request({
    url: '/maintenance',
    method: 'post',
    data
  })
}

/**
 * 更新保养记录
 */
export function updateMaintenance(data) {
  return request({
    url: '/maintenance',
    method: 'put',
    data
  })
}

/**
 * 删除保养记录
 */
export function deleteMaintenance(id) {
  return request({
    url: `/maintenance/${id}`,
    method: 'delete'
  })
}

/**
 * 导出保养记录
 */
export function exportMaintenance(params) {
  return request({
    url: '/maintenance/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

